const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('user', {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: " 用户id"
    },
    openid: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: "微信用户openid"
    },
    headimgurl: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: "用户头像"
    },
    user_name: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: " 用户昵称"
    },
    banned: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
      defaultValue: 0,
      comment: "用户是否封号,0 否，1是"
    },
    sex: {
      type: DataTypes.STRING(5),
      allowNull: true,
      comment: " 用户性别，0 为女，1 为男"
    },
    city: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: "用户地址"
    },
    first_time: {
      type: DataTypes.BOOLEAN,
      allowNull: true,
      defaultValue: 1,
      comment: "是否首次，1首次，0不是"
    },
    create_time: {
      type: DataTypes.DATE,
      allowNull: false,
      comment: " 用户创建时间"
    }
  }, {
    sequelize,
    tableName: 'users',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
